#include "IntArraySolution.hh"

int IntArraySolution::size = 0;

IntArraySolution::IntArraySolution(int *array): Solution(){
    this->array = new int[size];
    for (int i = 0; i < size; i++) this->array[i] = array[i];
}

IntArraySolution::IntArraySolution(): Solution(){
    array = new int[size];
}

IntArraySolution::~IntArraySolution() {
    delete [] array;
}

IntArraySolution::IntArraySolution(IntArraySolution &other): Solution(other){
    array = new int[size];
    for (int i = 0; i < size; i++) array[i] = other.array[i];
}

int IntArraySolution::get(int i){
    return array[i];
}

void IntArraySolution::set(int i, int value){
    array[i] = value;
    changed = true;
}

void IntArraySolution::initialize() {
    for (int i = 0; i < size; i++) array[i] = Random::getInstance()->getInt(2);
}

int IntArraySolution::length() {
    return IntArraySolution::size;
}

void IntArraySolution::send(ostream &os) {
    for (int i = 0; i < length(); i++) os << get(i);
    Solution::send(os);
}

Solution* IntArraySolution::copy(){
    return new IntArraySolution(*this);
}
